<?php


namespace App\Http\Controllers\applets\model;


use Illuminate\Support\Facades\DB;

class TeacherSnModel
{
    public static function queryWhere($where,$field){
        return DB::table('t_teacher_sn')
            ->leftJoin('t_admin_sn as a','t_teacher_sn.admin_sn_id','=','a.id')
            ->where($where)
            ->get($field);
    }

    public static function queryWhereCount($where){
        return DB::table('t_teacher_sn')->where($where)->count('id');
    }

    public static function queryClassInfo($where){
        $field = ['b.name','a.value','a.name','a.avatar','p.phone','d.username'];
        return DB::table('t_teacher_sn as t')
            ->leftJoin('t_admin_sn as a','t.admin_sn_id','=','a.id')
            ->leftJoin('t_parent_sn as p','a.id','=','p.admin_sn_id')
            ->leftJoin('t_batch as b','t.batch_id','=','b.id')
            ->leftJoin('t_admin as d','p.admin_id','=','d.id')
            ->where($where)
            ->get($field);
    }

    public static function add($param){
        return DB::table('t_teacher_sn')->insert($param);
    }

    public static function delete($where){
        return DB::table('t_teacher_sn')->where($where)->delete();
    }
}